package lily.phs.object;

import lily.phs.database.Constants;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;

public class EpidemicRecord implements Constants{
	private static final String[] PROJECTION = new String[] { 
		INDI_ID
	};
	
	private Context mContext;
	private int indi_id=0;
	private int indi_category=0;
	private String indi_name="";
	private String indi_parent_name="";
	private String indi_perid="";
	private int indi_sex=0;
	private String indi_born="";
	private String indi_full_born="";
	private int indi_full_unit=0;
	private String indi_work="";
	private String indi_phone="";
	private int indi_area=0;
	private String indi_province="";
	private String indi_city="";
	private String indi_country="";
	private String indi_town="";
	private String indi_village="";
	private String indi_number="";
	private int indi_job=0;
	private String indi_job_other="";
	private int indi_classification_a=0;
	private int indi_classification_b=0;
	private String indi_ill_date="";
	private String indi_diagnose_date="";
	private String indi_diagnose_time="";
	private String indi_die_date="";
	private int indi_disease_a=0;
    private String indi_other="";
    private String indi_disease_name="";
    private String indi_reason="";
    private String indi_orgnization="";
    private String indi_connect_phone="";
    private String indi_report="";
    private String indi_fill_date="";
    private String indi_remark="";
    private int indi_en=0;
    private int indi_check=-1;
    public EpidemicRecord(Context context){
		this.mContext = context;
	}
 	public int getIndi_id() {
		return indi_id;
	}
	public void setIndi_id(int indi_id) {
		this.indi_id = indi_id;
	}
	public int getIndi_category() {
		return indi_category;
	}
	public void setIndi_category(int indi_category) {
		this.indi_category = indi_category;
	}
	public String getIndi_name() {
		return indi_name;
	}
	public void setIndi_name(String indi_name) {
		this.indi_name = indi_name;
	}
	public String getIndi_parent_name() {
		return indi_parent_name;
	}
	public void setIndi_parent_name(String indi_parent_name) {
		this.indi_parent_name = indi_parent_name;
	}
	public String getIndi_perid() {
		return indi_perid;
	}
	public void setIndi_perid(String indi_perid) {
		this.indi_perid = indi_perid;
	}
	public int getIndi_sex() {
		return indi_sex;
	}
	public void setIndi_sex(int indi_sex) {
		this.indi_sex = indi_sex;
	}
	public String getIndi_born() {
		return indi_born;
	}
	public void setIndi_born(String indi_born) {
		this.indi_born = indi_born;
	}
	public String getIndi_full_born() {
		return indi_full_born;
	}
	public void setIndi_full_born(String indi_full_born) {
		this.indi_full_born = indi_full_born;
	}
	public int getIndi_full_unit() {
		return indi_full_unit;
	}
	public void setIndi_full_unit(int indi_full_unit) {
		this.indi_full_unit = indi_full_unit;
	}
	public String getIndi_work() {
		return indi_work;
	}
	public void setIndi_work(String indi_work) {
		this.indi_work = indi_work;
	}
	public String getIndi_phone() {
		return indi_phone;
	}
	public void setIndi_phone(String indi_phone) {
		this.indi_phone = indi_phone;
	}
	public int getIndi_area() {
		return indi_area;
	}
	public void setIndi_area(int indi_area) {
		this.indi_area = indi_area;
	}
	
	public String getIndi_province() {
		return indi_province;
	}
	public void setIndi_province(String indi_province) {
		this.indi_province = indi_province;
	}
	public String getIndi_city() {
		return indi_city;
	}
	public void setIndi_city(String indi_city) {
		this.indi_city = indi_city;
	}
	public String getIndi_country() {
		return indi_country;
	}
	public void setIndi_country(String indi_country) {
		this.indi_country = indi_country;
	}
	public String getIndi_town() {
		return indi_town;
	}
	public void setIndi_town(String indi_town) {
		this.indi_town = indi_town;
	}
	public String getIndi_village() {
		return indi_village;
	}
	public void setIndi_village(String indi_village) {
		this.indi_village = indi_village;
	}
	public String getIndi_number() {
		return indi_number;
	}
	public void setIndi_number(String indi_number) {
		this.indi_number = indi_number;
	}
	public int getIndi_job() {
		return indi_job;
	}
	public void setIndi_job(int indi_job) {
		this.indi_job = indi_job;
	}
	public String getIndi_job_other() {
		return indi_job_other;
	}
	public void setIndi_job_other(String indi_job_other) {
		this.indi_job_other = indi_job_other;
	}
	public int getIndi_classification_a() {
		return indi_classification_a;
	}
	public void setIndi_classification_a(int indi_classification_a) {
		this.indi_classification_a = indi_classification_a;
	}
	public int getIndi_classification_b() {
		return indi_classification_b;
	}
	public void setIndi_classification_b(int indi_classification_b) {
		this.indi_classification_b = indi_classification_b;
	}
	public String getIndi_ill_date() {
		return indi_ill_date;
	}
	public void setIndi_ill_date(String indi_ill_date) {
		this.indi_ill_date = indi_ill_date;
	}
	public String getIndi_diagnose_date() {
		return indi_diagnose_date;
	}
	public void setIndi_diagnose_date(String indi_diagnose_date) {
		this.indi_diagnose_date = indi_diagnose_date;
	}
	
	public String getIndi_diagnose_time() {
		return indi_diagnose_time;
	}
	public void setIndi_diagnose_time(String indi_diagnose_time) {
		this.indi_diagnose_time = indi_diagnose_time;
	}
	public String getIndi_die_date() {
		return indi_die_date;
	}
	public void setIndi_die_date(String indi_die_date) {
		this.indi_die_date = indi_die_date;
	}
	public int getIndi_disease_a() {
		return indi_disease_a;
	}
	public void setIndi_disease_a(int indi_disease_a) {
		this.indi_disease_a = indi_disease_a;
	}

	public String getIndi_other() {
		return indi_other;
	}
	public void setIndi_other(String indi_other) {
		this.indi_other = indi_other;
	}
	public String getIndi_disease_name() {
		return indi_disease_name;
	}
	public void setIndi_disease_name(String indi_disease_name) {
		this.indi_disease_name = indi_disease_name;
	}
	public String getIndi_reason() {
		return indi_reason;
	}
   public void setIndi_reason(String indi_reason) {
		this.indi_reason = indi_reason;
	}
	public String getIndi_orgnization() {
		return indi_orgnization;
	}
	public void setIndi_orgnization(String indi_orgnization) {
		this.indi_orgnization = indi_orgnization;
	}
	public String getIndi_connect_phone() {
		return indi_connect_phone;
	}
	public void setIndi_connect_phone(String indi_connect_phone) {
		this.indi_connect_phone = indi_connect_phone;
	}
	public String getIndi_report() {
		return indi_report;
	}
	public void setIndi_report(String indi_report) {
		this.indi_report = indi_report;
	}
	public String getIndi_fill_date() {
		return indi_fill_date;
	}
	public void setIndi_fill_date(String indi_fill_date) {
		this.indi_fill_date = indi_fill_date;
	}
	public String getIndi_remark() {
		return indi_remark;
	}
	public void setIndi_remark(String indi_remark) {
		this.indi_remark = indi_remark;
	}	
	
	public int getIndi_en() {
		return indi_en;
	}
	public void setIndi_en(int indi_en) {
		this.indi_en = indi_en;
	}
		
	public int getIndi_check() {
		return indi_check;
	}
	public void setIndi_check(int indi_check) {
		this.indi_check = indi_check;
	}
	
	
	public void insertEpidemicRecord(){
		ContentValues value = new ContentValues();
		value.put(INDI_ID,this.getIndi_id());
		value.put(INDI_CATEGORY,this.getIndi_category());
	    value.put(INDI_NAME,this.getIndi_name());
	    value.put(INDI_PARENT_NAME,this.getIndi_parent_name());
	    value.put(INDI_PERID,this.getIndi_perid());
	    value.put(INDI_SEX,this.getIndi_sex());
	    value.put(INDI_BORN,this.getIndi_born());
	    value.put(INDI_FULL_BORN,this.getIndi_full_born());
	    value.put(INDI_FULL_UNIT,this.getIndi_full_unit());
	    value.put(INDI_WORK,this.getIndi_work());
	    value.put(INDI_PHONE,this.getIndi_phone());
	    value.put(INDI_AREA,this.getIndi_area());
	    value.put(INDI_NUMBER,this.getIndi_number());
	    value.put(INDI_PROVINCE,this.getIndi_province());
	    value.put(INDI_CITY,this.getIndi_city());
	    value.put(INDI_COUNTRY,this.getIndi_country());
	    value.put(INDI_TOWN,this.getIndi_town());
	    value.put(INDI_VILLAGE,this.getIndi_village());
	    value.put(INDI_JOB,this.getIndi_job());
	    value.put(INDI_JOB_OTHER,this.getIndi_job_other());
	    value.put(INDI_CLASSIFICATION_A,this.getIndi_classification_a());
	    value.put(INDI_CLASSIFICATION_B,this.getIndi_classification_b());
	    value.put(INDI_ILL_DATE,this.getIndi_ill_date());
	    value.put(INDI_DIAGNOSE_DATE,this.getIndi_diagnose_date());
	    value.put(INDI_DIAGNOSE_TIME,this.getIndi_diagnose_time());
	    value.put(INDI_DIE_DATE,this.getIndi_die_date());
	    value.put(INDI_DISEASE_A,this.getIndi_disease_a());
	    value.put(INDI_OTHER,this.getIndi_other());
	    value.put(INDI_DISEASE_NAME,this.getIndi_disease_name());
	    value.put(INDI_REASON,this.getIndi_reason());
	    value.put(INDI_ORGNIZATION,this.getIndi_orgnization());
	    value.put(INDI_CONNECT_PHONE,this.getIndi_connect_phone());
	    value.put(INDI_REPORT,this.getIndi_report());
	    value.put(INDI_FILL_DATE,this.getIndi_fill_date());
	    value.put(INDI_REMARK,this.getIndi_remark());
	    value.put(INDI_EN,this.getIndi_en());
	    value.put(INDI_CHECK,this.getIndi_check());
	    mContext.getContentResolver().insert(CONTENT_URI_TB20, value);
	    System.out.println("insert");
	}
	
      public void selectEpidemicRecord(int indiid){
		
		String where = INDI_ID + "=" + indiid ;
		Cursor cursor = mContext.getContentResolver().query(CONTENT_URI_TB20, null, where, null, null);
	    System.out.println("cursor="+cursor.getCount());
		while(cursor.moveToNext()){
			this.indi_id=cursor.getInt(cursor.getColumnIndex(INDI_ID));
		    this.indi_category= cursor.getInt(cursor.getColumnIndex(INDI_CATEGORY));
		    this.indi_name = cursor.getString(cursor.getColumnIndex(INDI_NAME));
		    this.indi_parent_name = cursor.getString(cursor.getColumnIndex(INDI_PARENT_NAME));
		    this.indi_perid = cursor.getString(cursor.getColumnIndex(INDI_PERID));
		    this.indi_sex= cursor.getInt(cursor.getColumnIndex(INDI_SEX));
		    this.indi_born = cursor.getString(cursor.getColumnIndex(INDI_BORN));
		    this.indi_full_born= cursor.getString(cursor.getColumnIndex(INDI_FULL_BORN));
		    this.indi_full_unit= cursor.getInt(cursor.getColumnIndex(INDI_FULL_UNIT));
		    this.indi_work = cursor.getString(cursor.getColumnIndex(INDI_WORK));
		    this.indi_phone = cursor.getString(cursor.getColumnIndex(INDI_PHONE));
		    this.indi_area= cursor.getInt(cursor.getColumnIndex(INDI_AREA));
		    this.indi_number= cursor.getString(cursor.getColumnIndex(INDI_NUMBER));
		    this.indi_province= cursor.getString(cursor.getColumnIndex(INDI_PROVINCE));
		    this.indi_city= cursor.getString(cursor.getColumnIndex(INDI_CITY));
		    this.indi_country= cursor.getString(cursor.getColumnIndex(INDI_COUNTRY));
		    this.indi_town= cursor.getString(cursor.getColumnIndex(INDI_TOWN));
		    this.indi_village= cursor.getString(cursor.getColumnIndex(INDI_VILLAGE));
		    this.indi_job= cursor.getInt(cursor.getColumnIndex(INDI_JOB));
		    this.indi_job_other= cursor.getString(cursor.getColumnIndex(INDI_JOB_OTHER));
		    this.indi_classification_a= cursor.getInt(cursor.getColumnIndex(INDI_CLASSIFICATION_A));
		    this.indi_classification_b= cursor.getInt(cursor.getColumnIndex(INDI_CLASSIFICATION_B));
		    this.indi_ill_date = cursor.getString(cursor.getColumnIndex(INDI_ILL_DATE));
		    this.indi_diagnose_date = cursor.getString(cursor.getColumnIndex(INDI_DIAGNOSE_DATE));
		    this.indi_diagnose_time = cursor.getString(cursor.getColumnIndex(INDI_DIAGNOSE_TIME));
		    this.indi_die_date = cursor.getString(cursor.getColumnIndex(INDI_DIE_DATE));
		    this.indi_disease_a= cursor.getInt(cursor.getColumnIndex(INDI_DISEASE_A));
		    this.indi_other = cursor.getString(cursor.getColumnIndex(INDI_OTHER));
		    this.indi_disease_name = cursor.getString(cursor.getColumnIndex(INDI_DISEASE_NAME));
		    this.indi_reason = cursor.getString(cursor.getColumnIndex(INDI_REASON));
		    this.indi_orgnization = cursor.getString(cursor.getColumnIndex(INDI_ORGNIZATION));
		    this.indi_connect_phone = cursor.getString(cursor.getColumnIndex(INDI_CONNECT_PHONE));
		    this.indi_report = cursor.getString(cursor.getColumnIndex(INDI_REPORT));
		    this.indi_fill_date = cursor.getString(cursor.getColumnIndex(INDI_FILL_DATE));
		    this.indi_remark = cursor.getString(cursor.getColumnIndex(INDI_REMARK));
		    this.indi_en = cursor.getInt(cursor.getColumnIndex(INDI_EN));
		    this.indi_check = cursor.getInt(cursor.getColumnIndex(INDI_CHECK));
		 }
		cursor.close();
      }
      
      public void selectCode(int indiid){
  		Cursor cursor = mContext.getContentResolver().query(CONTENT_URI_TB20, PROJECTION,
  				INDI_ID + "=" + indiid + "", null, null);
  		System.out.println("cursor.getCount="+cursor.getCount());
  		while(cursor.moveToNext()){
  			this.indi_id = cursor.getInt(cursor.getColumnIndex(INDI_ID));
  			
  			break;
  		}
  		cursor.close();
  	}
      
       public void updateEpidemicRecord(int indiid){
  		   ContentValues value = new ContentValues();
  		 value.put(INDI_ID,this.getIndi_id());
 		value.put(INDI_CATEGORY,this.getIndi_category());
 	    value.put(INDI_NAME,this.getIndi_name());
 	    value.put(INDI_PARENT_NAME,this.getIndi_parent_name());
 	    value.put(INDI_PERID,this.getIndi_perid());
 	    value.put(INDI_SEX,this.getIndi_sex());
 	    value.put(INDI_BORN,this.getIndi_born());
 	    value.put(INDI_FULL_BORN,this.getIndi_full_born());
 	    value.put(INDI_FULL_UNIT,this.getIndi_full_unit());
 	    value.put(INDI_WORK,this.getIndi_work());
 	    value.put(INDI_PHONE,this.getIndi_phone());
 	    value.put(INDI_AREA,this.getIndi_area());
 	    value.put(INDI_NUMBER,this.getIndi_number());
 	    value.put(INDI_PROVINCE,this.getIndi_province());
 	    value.put(INDI_CITY,this.getIndi_city());
 		value.put(INDI_COUNTRY,this.getIndi_country());
 		value.put(INDI_TOWN,this.getIndi_town());
 		value.put(INDI_VILLAGE,this.getIndi_village());
 	    value.put(INDI_JOB,this.getIndi_job());
 	    value.put(INDI_JOB_OTHER,this.getIndi_job_other());
 	    value.put(INDI_CLASSIFICATION_A,this.getIndi_classification_a());
 	    value.put(INDI_CLASSIFICATION_B,this.getIndi_classification_b());
 	    value.put(INDI_ILL_DATE,this.getIndi_ill_date());
 	    value.put(INDI_DIAGNOSE_DATE,this.getIndi_diagnose_date());
 	   value.put(INDI_DIAGNOSE_TIME,this.getIndi_diagnose_time());
 	    value.put(INDI_DIE_DATE,this.getIndi_die_date());
 	    value.put(INDI_DISEASE_A,this.getIndi_disease_a());
 	    value.put(INDI_OTHER,this.getIndi_other());
 	    value.put(INDI_DISEASE_NAME,this.getIndi_disease_name());
 	    value.put(INDI_REASON,this.getIndi_reason());
 	    value.put(INDI_ORGNIZATION,this.getIndi_orgnization());
 	    value.put(INDI_CONNECT_PHONE,this.getIndi_connect_phone()); 	    
 	    value.put(INDI_REPORT,this.getIndi_report());
 	    value.put(INDI_FILL_DATE,this.getIndi_fill_date());
 	    value.put(INDI_REMARK,this.getIndi_remark());
 	   
 	    String where = INDI_ID + "=" + indiid ; 
 	    mContext.getContentResolver().update(CONTENT_URI_TB20, value, where, null);
      }
       
       public void updateEN(int indiid){
  		   ContentValues value = new ContentValues();
  		 String where = INDI_ID + "=" + indiid ; 
  		value.put(INDI_EN,this.getIndi_en());
  		value.put(INDI_CHECK,this.getIndi_check());
  	    mContext.getContentResolver().update(CONTENT_URI_TB20, value, where, null);
  		   }

       
       public void delectEpidemicRecord(int indiid){
    	   String where = INDI_ID + "=" + indiid ; 
   		mContext.getContentResolver().delete(CONTENT_URI_TB20,where, null);
   		
   	}
}
